package com.toocms.jinjuhang.ui.index

import androidx.databinding.ObservableField
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.data.index.ConfigureItemData
import com.toocms.jinjuhang.utils.RuleSkip
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.base.MultiItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

/**
 * 单图
 *
 * @constructor
 *
 * @param viewModel
 */
class IndexModuleOneItemModel(viewModel: BaseViewModel<*>, images: List<ConfigureItemData>) :
    MultiItemViewModel<BaseViewModel<*>>(viewModel) {

    val imageUrlObservableField by lazy {
        ObservableField(images[0].cover_path)
    }

    val imageClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        val itemData = images[0]
        RuleSkip.skip(itemData.target_rule, itemData.param)
    })


    init {
        itemType = Constants.RecyclerViewItemType.ITEM_TYPE_FOUR
    }
}